<template>

</template>
<script>
	import config from "@/config/config.js";
	import xcHttpUtils from '@/library/xcore/js/XcHttpUtils.js';
	import xcViewUtils from '@/library/xcore/js/XcViewUtils.js';
	import {
		xsStringUtils,
		xsDateUtils,
		xsArrayUtils
	} from 'xstack-for-javascript';

	export default {
		props: {
			fstatusList: {
				type: Array,
				default: []
			},
			flogicList: {
				type: Array,
				default: []
			},
		},
		watch: {
			'fstatusList': {
				handler(newVal, oldVal) {
					let that = this;
				},
			},
		},
		data() {
			return {
				config: config,
				xsStringUtils: xsStringUtils,
				xsDateUtils: xsDateUtils,
				xsArrayUtils: xsArrayUtils,
				sp: {
					clickFlogicId: null,
					callbackFunc: null
				},
				sr: {},
				control: {}
			}
		},
		created() {
			let that = this;
			that.xinit();
		},
		methods: {
			xinit() {
				let that = this;
			},
			public_show(clickFlogicId, callbackFunc) {
				let that = this;
				that.sp.clickFlogicId = clickFlogicId;
				that.sp.callbackFunc = callbackFunc;
				let clickFlogicIndex = xsArrayUtils.indexesOfByObjectKey(that.flogicList, 'id', clickFlogicId);

				// add fstatus
				let tt = that.fstatusList.length + 1;
				that.fstatusList.push({
					"id": tt,
					"name": "审核状态" + tt
				});


				// add child flogic
				that.flogicList.push({
					"id": 300 + tt,
					"logictype": "all",
					"name": "",
					"flowfstatus_id": tt,
					"pass_typefstatus_id": that.flogicList[clickFlogicIndex]["pass_typefstatus_id"]
				});

				// update parent
				that.flogicList[clickFlogicIndex]["pass_typefstatus_id"] = tt;

				// update parent flogic
				// let childFlogicIndexes = xsArrayUtils.indexesOfByObjectKey(that.flogicList, 'flowfstatus_id', clickFlogicId);
				// for(let i in childFlogicIndexes){
				// 	let index = childFlogicIndexes[i];
				// 	that.flogicList[index]["flowfstatus_id"] = tt;
				// }



				// add parent flogic
				// that.flogicList.push({
				// 	"id": 300 + tt,
				// 	"logictype": "all",
				// 	"name": "",
				// 	"flowfstatus_id": clickFlogicId,
				// 	"pass_typefstatus_id": tt
				// });

				that.sp.callbackFunc();
			},
			public_reset() {
				let that = this;
				that.public_show();
			},
			public_close() {
				let that = this;
				that.control.visible = false;
			},
		}
	}
</script>

<style lang="scss">
	.xp-content {
		padding-bottom: $uni-spacing-col-base;
	}
</style>